//
//  UIBarButtonItem+Extension.m
//  OCSinaWeiBo
//
//  Created by Apple on 15/11/1.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)


+ (UIBarButtonItem *)addNavigationItem:(NSString *)nameN hightlightedImageName:(NSString *)nameH
{
    UIButton *button = [[UIButton alloc] init];
    
    [button setImage:[UIImage imageNamed:nameN] forState:UIControlStateNormal];
    
    [button setImage:[UIImage imageNamed:nameH] forState:UIControlStateHighlighted];
    
    [button sizeToFit];
    
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}

+ (instancetype)barButtonItemWith:(NSString *)imageName
{
    UIButton *button = [[UIButton alloc] init];
    
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    
    NSString *nameH = [NSString stringWithFormat:@"%@_highlighted", imageName];
    
    [button setImage:[UIImage imageNamed:nameH] forState:UIControlStateHighlighted];
    
    [button sizeToFit];
    
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}

@end
